'use strict';

const Sequelize = require('sequelize');
const sequelize = require('../plugins/db');

const Model = Sequelize.Model;
class Comment extends Model {}

// 静态属性：主键字段名称
Comment.pk = 'id';
Comment.init({
    id: {
      type: Sequelize.INTEGER,
      autoIncrement: true,
      primaryKey: true,
      comment: '评论id'
    },
    path: {
      type:  Sequelize.STRING,
      allowNull: false,
      comment: 'path'
    },
    member_id: {
      type: Sequelize.INTEGER,
      allowNull: false,
      comment: '会员id'
    },
    comment: {
      type: Sequelize.TEXT,
      comment: '评论内容'
    },
    reply_id: {
      type: Sequelize.INTEGER,
      defaultValue: 0,
      comment: '回复id'
    },
    likes: {
      type: Sequelize.INTEGER,
      defaultValue: 0,
      comment: '点赞数'
    },
    status: {
      type: Sequelize.STRING,
      defaultValue: 'normal',
      comment: '状态'
    }
}, {
    sequelize,
    tableName: 'comment',
    freezeTableName: true,
    timestamps: true
});
module.exports = Comment;
